package main

import (
	"log"
	"net"
)

func init() {
	RegisterDbFirewall("mysql", MysqlFirewallHandle)
}

func MysqlFirewallHandle(server net.Conn, client net.Conn, firewalls []*FirewallBlock, exit chan bool) {
	if _, err := readAndWrite(client, server); checkErrorNotEOF(err) {
		exit <- true
		return
	}

	bs, err := readPacket(server)
	if checkErrorNotEOF(err) {
		return
	}
	log.Println(string(bs))
	client.Write(bs)
	bs, err = readPacket(client)
	server.Write(bs)

	bs, err = readPacket(server)
	log.Println(string(bs))

}
